package com.atao.example.stream05;

import java.util.Arrays;
import java.util.List;

/**
 * @author 阿涛
 * @date 2021-03-07
 */
public class Test {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
        list.stream().forEach(System.out::print);
        System.out.println("\n==========================");
        list.parallelStream().forEach(System.out::print);
        System.out.println("\n==========================");

        System.out.println("==========================");
        //todo 并行流，多个线程执行
        List<Integer> numebers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9);
        numebers.parallelStream().forEach(System.out::print);
        System.out.println("\n===========================");
        numebers.stream().sequential().forEach(System.out::print);
        System.out.println("\n");
    }
}
